package com.dankegongyu.lib.http.func;

import com.dankegongyu.lib.http.exception.ApiException;

import io.reactivex.Observable;
import io.reactivex.functions.Function;

/**
 * 错误处理：
 * 1、http请求相关的错误，例如：404，403，socket timeout等等；
 * 2、应用数据的错误会抛{@link com.dankegongyu.lib.http.exception.ServerException}，最后也会走到这里统一处理
 *
 * @author wpq
 * @version 1.0
 */
public class ApiErrorFunction<T> implements Function<Throwable, Observable<T>> {
    @Override
    public Observable<T> apply(Throwable throwable) throws Exception {
        return Observable.error(ApiException.handleException(throwable));
    }
}
